﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TimViec.MP
{
    public partial class NTD : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
            if (!IsPostBack)
            {                
                LoadData();
            }
        }
        public void LoadData()
        {
            if (Session["NTD"] != null)
            {
                pnLogin.Visible = true;
                pnNoLogin.Visible = false;
                DAL.UserTuyenDung user = BLL.TuyenDung.UserHelper.Get_UserEmail(Session["NTD"].ToString());
                lbUser.Text = user.TenCongTy;
            }
            else
            {
                pnLogin.Visible = false;
                pnNoLogin.Visible = true;
            }
        }
        protected void lbtLogOut_Click(object sender, EventArgs e)
        {
            Session.Remove("NTD");
            Response.Redirect("/nha-tuyen-dung.html");
        }
        protected void btLogin_Click(object sender, EventArgs e)
        {
            if (BLL.TuyenDung.UserHelper.Login(txtUserName.Text, txtMK.Text))
            {
                Session["NTD"] = txtUserName.Text;
                Response.Redirect("/nha-tuyen-dung/tai-khoan.html");
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "redirectMe", "alert('Sai tên đăng nhập hoặc mật khẩu!');", true);
                return;
            }
        }
        
    }
}